import QtQuick
import QtQuick.Controls
import QtQuick3D
import QtQuick3D.Helpers

import QtQuickRO
import QtQuick3D.Physics

import "../Actors"
import "../PlayerController"
import "../Character"
import Utils
import MineCraftUtils

import Quick3DAssets.Home

Node {
    id: scene
    property alias playerSpawner:playerSpawner
    property alias characterComp:playerSpawner.sourceComponent//玩家角色组件
    EntitySpawner{//玩家出生点
        id:playerSpawner

        x: -164.468
        y: 741.761
        eulerRotation.y: -180
        z: 674.83905
    }

    //场景灯光
    DirectionalLight{
        eulerRotation.z: -82.43424
        eulerRotation.y: 87.8755
        eulerRotation.x: -67.51973
        castsShadow: true
        shadowFactor: 100
        shadowMapQuality: Light.ShadowMapQualityLow
    }



    Home{//场景模型
        id:homeModel
        CraftTable{//工作台
            x: 350
            y: 750
            z: 450
        }

        Bed{
            x: -350
            y: 700
            z: 500

        }

        MineCraftBlock{
            type:BlockMeta.GoldBlock
            x: -350
            y: 850
            z: 750
        }

        Chest{
            x: -350
            y: 700
            z: 750

        }

        StaticRigidBody{//进入关卡的触发器
            id:enterHole
            x: 0
            y: 750
            z: 600

            collisionShapes: BoxShape{
                extents: Qt.vector3d(200,600,200)
            }

            InteractiveTrigger{
                type:"enterHole"

                host:enterHole
                descript: "进入坑洞（开始游戏）"

                collisionShapes: BoxShape{
                    extents: Qt.vector3d(250,600,250)
                }
            }
        }

        IdHacker{
            id:hacker
            target:homeModel

            property Texture home_c4d_tex_home_RGBA_png_texture
            property PrincipledMaterial mc_material_material
            property Model home

            Component.onCompleted: {
                home_c4d_tex_home_RGBA_png_texture.magFilter = Texture.Nearest
                mc_material_material.alphaMode = PrincipledMaterial.Mask
                mc_material_material.roughness = 1.0
                home.pickable = true
            }

        }

        StaticRigidBody {//场景碰撞箱
            id: staticRigidBody
            x: 0
            z: 0
            collisionShapes: TriangleMeshShape {
                source: hacker.home.source
            }
        }

    }

    PhysicsWorld {//物理效果
        id: physicsWorld
        running: true
        scene: scene
        //forceDebugDraw: true
    }

    Node {
        id: __materialLibrary__

        PrincipledMaterial {
            id: principledMaterial
            objectName: "New Material"
        }
    }
}
